#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int n = 0;
    int m = 0;
    int arr[4][2];
    scanf("%d %d", &n, &m);
    for (int i = 0; i < 2 * n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }
    int k = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (arr[i][j] != arr[i + n][j])
            {
                printf("No\n");
                k = 1;
                break;
            }
        }
        if (k == 1)
        {
            break;
        }
    }
    if (k == 0)
    {
        printf("Yes\n");
    }
    return 0;
}